home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 726-750 / 741 / rkrm_lib1 / rkrm_lib1.lha / Intuition / Requesters_Alerts / easyrequest.c < prev   
C/C++ Source or Header  |  1992-09-03  |  3KB  |  112 lines

  1. ;/* easyrequest.c - Execute me to compile me with SAS C 5.10
  2. LC -b1 -cfistq -v -y -j73 easyrequest.c
  3. Blink FROM LIB:c.o,easyrequest.o TO easyrequest LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5. */
  6.  
  7. /*
  8. Copyright (c) 1992 Commodore-Amiga, Inc.
  9.  
  10. This example is provided in electronic form by Commodore-Amiga, Inc. for
  11. use with the "Amiga ROM Kernel Reference Manual: Libraries", 3rd Edition,
  12. published by Addison-Wesley (ISBN 0-201-56774-1).
  13.  
  14. The "Amiga ROM Kernel Reference Manual: Libraries" contains additional
  15. information on the correct usage of the techniques and operating system
  16. functions presented in these examples.  The source and executable code
  17. of these examples may only be distributed in free electronic form, via
  18. bulletin board or as part of a fully non-commercial and freely
  19. redistributable diskette.  Both the source and executable code (including
  20. comments) must be included, without modification, in any copy.  This
  21. example may not be published in printed form or distributed with any
  22. commercial product.  However, the programming techniques and support
  23. routines set forth in these examples may be used in the development
  24. of original executable software products for Commodore Amiga computers.
  25.  
  26. All other rights reserved.
  27.  
  28. This example is provided "as-is" and is subject to change; no
  29. warranties are made.  All use is at your own risk. No liability or
  30. responsibility is assumed.
  31. */
  32.  
  33.  
  34. /*
  35. ** easyrequest.c - show the use of an easy requester.
  36. */
  37. #define INTUI_V36_NAMES_ONLY
  38.  
  39. #include <exec/types.h>
  40. #include <intuition/intuition.h>
  41.  
  42. #include <clib/exec_protos.h>
  43. #include <clib/intuition_protos.h>
  44.  
  45. #include <stdio.h>
  46.  
  47. #ifdef LATTICE
  48. int CXBRK(void)    { return(0); }  /* Disable Lattice CTRL/C handling */
  49. int chkabort(void) { return(0); }  /* really */
  50. #endif
  51.  
  52. /* declare the easy request structure.
  53. ** this uses many features of EasyRequest(), including:
  54. **     multiple lines of body text separated by '\n'.
  55. **     variable substitution of a string (%s) in the body text.
  56. **     multiple button gadgets separated by '|'.
  57. **     variable substitution in a gadget (long decimal '%ld').
  58. */
  59. struct EasyStruct myES =
  60.     {
  61.     sizeof(struct EasyStruct),
  62.     0,
  63.     "Request Window Name",
  64.     "Text for the request\nSecond line of %s text\nThird line of text for the request",
  65.     "Yes|%ld|No",
  66.     };
  67.  
  68. struct Library *IntuitionBase;
  69.  
  70. /*
  71. ** Main routine to show the use of EasyRequest()
  72. */
  73. VOID main (int argc, char **argv)
  74. {
  75. LONG answer;
  76. LONG number;
  77.  
  78. number = 3125794;  /* for use in the middle button */
  79.  
  80. if (IntuitionBase = OpenLibrary("intuition.library",37))
  81.     {
  82.     /* note in the variable substitution:
  83.     **     the string goes in the first open variable (in body text).
  84.     **     the number goes in the second open (gadget text).
  85.     */
  86.     answer = EasyRequest(NULL, &myES, NULL, "(Variable)", number);
  87.  
  88.     /* Process the answer.  Note that the buttons are numbered in
  89.     ** a strange order.  This is because the rightmost button is
  90.     ** always a negative reply.  The code can use this if it chooses,
  91.     ** with a construct like:
  92.     **
  93.     **     if (EasyRequest())
  94.     **          positive_response();
  95.     */
  96.     switch (answer)
  97.         {
  98.         case 1:
  99.             printf("selected 'Yes'\n");
  100.             break;
  101.         case 2:
  102.             printf("selected '%ld'\n", number);
  103.             break;
  104.         case 0:
  105.             printf("selected 'No'\n");
  106.             break;
  107.         }
  108.  
  109.     CloseLibrary(IntuitionBase);
  110.     }
  111. }
  112.